//
//  HJWebSocketManager.h
//  KaiChat
//
//  Created by lx on 2023/10/16.
//

#import <Foundation/Foundation.h>
#import "HJMessageDto.h"

NS_ASSUME_NONNULL_BEGIN



@class HJWebSocketManager, HJDataPacketHeader;

@protocol HJWebSocketManagerDelegate <NSObject>

@optional

- (void)webSocket:(HJWebSocketManager *)webSocketManager didReceiveMessage:(NSDictionary *)message;
- (void)webSocket:(HJWebSocketManager *)webSocketManager didConnectFail:(NSError *)error;

 
@end


@interface HJWebSocketManager : NSObject


- (void)addDelegate:(id<HJWebSocketManagerDelegate>)delegate;
- (void)removeDelegate:(id<HJWebSocketManagerDelegate>)delegate;

- (void)sendMessageWithDto:(HJMessageDto *)dto complete:(void (^__nullable)(NSDictionary * _Nullable data, NSError  * _Nullable error))complete;
- (BOOL)sendData:(nullable NSData *)data error:(NSError **)error;

- (void)tryConnect;
- (void)connect;
- (void)reconnect;
- (void)disconnect;
+ (instancetype)shareManager;

@end

NS_ASSUME_NONNULL_END
